<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring4-4.dtd">
<html lang="zh-cn" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">

<head>
	<base th:href="@{/}" href="">
	<meta charset="utf-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge" />
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta name="viewport"
		content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
	<title>TMS-系统设置</title>
	<link rel="icon" th:href="@{/favicon.ico}" href="../../static/favicon.ico" type="image/x-icon" />
	<link rel="shortcut icon" th:href="@{/favicon.ico}" href="../../static/favicon.ico" type="image/x-icon" />
	<link rel="stylesheet" type="text/css" th:href="@{/admin/css/admin.css}" href="../../static/admin/css/admin.css" />
	<link rel="stylesheet" type="text/css" th:href="@{/lib/semantic/semantic.min.css}"
		href="../../static/lib/semantic/semantic.min.css" />
	<link rel="stylesheet" th:href="@{/lib/toastr/toastr.css}" href="../../static/lib/toastr/toastr.css" />
	<script th:replace="admin/template :: baiduTongji"></script>
</head>

<body>
	<div th:replace="admin/index :: sidebar-menu"></div>
	<div th:replace="admin/index :: top-fixed-menu"></div>
	<div class="pusher ad-index-content">
		<div class="ad-index-container">
			<div th:replace="admin/index :: rail-menu"></div>
			<div id="context">
				<div style="height: 70px;"></div>
				<div class="ui celled grid" style="margin-top: 0;">
					<div class="three wide column tms-menus">
						<div class="ui fluid vertical pointing menu" data-tab="mail">
							<a class="active item"><i class="mail icon"></i> 邮箱服务设置</a>
						</div>
						<div class="ui fluid vertical pointing menu" data-tab="menus">
							<a class="item"><i class="content icon"></i> 菜单功能设置</a>
						</div>
					</div>
					<div class="thirteen wide stretched column">
						<div class="ui basic segment tms-data-panel tms-mail">
							<div class="ui form fm-mail-setting">
								<div class="required field">
									<label>主机</label> <input type="text" name="host" th:value="${mail.host}" />
								</div>
								<div class="required field">
									<label>端口</label> <input type="text" name="port" th:value="${mail.port}" />
								</div>
								<div class="required field">
									<label>用户名</label> <input type="text" name="username" th:value="${mail.username}" />
								</div>
								<div class="required field">
									<label>密码</label> <input type="password" name="password"
										th:value="${mail.password}" />
								</div>
								<div class="field">
									<label>测试邮箱</label> <input type="text" name="addr" />
								</div>
								<div class="ui button btn-test-setting">发送测试邮件</div>
								<div class="ui blue submit button btn-save-setting">保存</div>
							</div>
						</div>
						<div class="ui basic segment tms-data-panel tms-menus" style="display: none;">
							<div class="ui form fm-menus-setting">
								<div class="ui list">
									<div class="item">
										<div class="ui toggle checkbox">
											<input th:if="${menus.chat}" type="checkbox" checked name="chat"> <input
												th:unless="${menus.chat}" type="checkbox" name="chat">
											<label>团队沟通</label>
										</div>
									</div>
									<div class="item">
										<div class="ui toggle checkbox">
											<input th:if="${menus.blog}" type="checkbox" checked name="blog"> <input
												th:unless="${menus.blog}" type="checkbox" name="blog">
											<label>团队博文</label>
										</div>
									</div>
									<div class="item">
										<div class="ui toggle checkbox">
											<input th:if="${menus.dynamic}" type="checkbox" checked name="dynamic">
											<input th:unless="${menus.dynamic}" type="checkbox" name="dynamic">
											<label>翻译动态</label>
										</div>
									</div>
									<div class="item">
										<div class="ui toggle checkbox">
											<input th:if="${menus.translate}" type="checkbox" checked name="translate">
											<input th:unless="${menus.translate}" type="checkbox" name="translate">
											<label>翻译管理</label>
										</div>
									</div>
									<div class="item">
										<div class="ui toggle checkbox">
											<input th:if="${menus._import}" type="checkbox" checked name="import">
											<input th:unless="${menus._import}" type="checkbox" name="import">
											<label>导入导出</label>
										</div>
									</div>
									<div class="item">
										<div class="ui toggle checkbox">
											<input th:if="${menus.project}" type="checkbox" checked name="project">
											<input th:unless="${menus.project}" type="checkbox" name="project">
											<label>项目管理</label>
										</div>
									</div>
									<div class="item">
										<div class="ui toggle checkbox">
											<input th:if="${menus.language}" type="checkbox" checked name="language">
											<input th:unless="${menus.language}" type="checkbox" name="language">
											<label>语言管理</label>
										</div>
									</div>
									<div class="item">
										<div class="ui toggle checkbox">
											<input th:if="${menus.user}" type="checkbox" checked name="user"> <input
												th:unless="${menus.user}" type="checkbox" name="user">
											<label>用户管理</label>
										</div>
									</div>
									<div class="item">
										<div class="ui toggle checkbox">
											<input th:if="${menus.link}" type="checkbox" checked name="link"> <input
												th:unless="${menus.link}" type="checkbox" name="link">
											<label>系统外链</label>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<div th:include="admin/template :: ad-page-common"></div>
	<script type="text/javascript" th:src="@{/admin/js/deps-base.js}" src="../../static/admin/js/deps-base.js"></script>
	<script type="text/javascript" th:src="@{/admin/js/admin.js}" src="../../static/admin/js/admin.js"></script>
	<script type="text/javascript">
		jQuery(function ($) {

			var baseURL = Utils.getBaseURL();

			var _tab = url('?tab');
			if (!_tab) _tab = 'mail';

			var $menu = $('.tms-menus .menu[data-tab="' + _tab + '"]');

			$('.tms-menus > .menu > a.item').removeClass('active');
			$menu.children('a.item').addClass('active');

			$('.tms-data-panel').hide();
			$('.tms-' + _tab).show();

			$('.tms-menus > .menu').click(function (event) {
				var tab = $(event.currentTarget).attr('data-tab');
				window.location.href = url('path') + '?tab=' + tab;
			});

			$('.button.btn-test-setting').click(
				function (event) {
					$.post('admin/setting/mail/test', Utils
						.formData('.ui.form.fm-mail-setting'),
						function (data, textStatus, xhr) {
							if (data.success) {
								toastr.success('测试邮件发送成功!');
							} else {
								toastr.error(data.data, '测试邮件发送失败!');
							}
						});
				});

			$('.button.btn-save-setting').click(
				function (event) {
					$.post('admin/setting/mail/createOrUpdate', Utils
						.formData('.ui.form.fm-mail-setting'),
						function (data, textStatus, xhr) {
							if (data.success) {
								toastr.success('保存成功!');
							} else {
								toastr.error(data.data, '保存失败!');
							}
						});
				});

			$('.fm-menus-setting .ui.checkbox').checkbox({
				onChange: function () {
					$.post('admin/setting/menus/save', {
						chat: $('input[name="chat"]').parent(
							'.checkbox').checkbox('is checked'),
						blog: $('input[name="blog"]').parent(
							'.checkbox').checkbox('is checked'),
						dynamic: $('input[name="dynamic"]').parent(
							'.checkbox').checkbox('is checked'),
						translate: $('input[name="translate"]')
							.parent('.checkbox').checkbox(
								'is checked'),
						_import: $('input[name="import"]').parent(
							'.checkbox').checkbox('is checked'),
						project: $('input[name="project"]').parent(
							'.checkbox').checkbox('is checked'),
						language: $('input[name="language"]').parent(
							'.checkbox').checkbox('is checked'),
						user: $('input[name="user"]').parent(
							'.checkbox').checkbox('is checked'),
						link: $('input[name="link"]').parent(
							'.checkbox').checkbox('is checked')
					}, function (data, textStatus, xhr) {
						if (data.success) {
							toastr.success('保存成功!');
						} else {
							toastr.error(data.data, '保存失败!');
						}
					});
				}
			});

		});
	</script>
</body>

</html>